#include <bits/stdc++.h>
#define ll long long
using namespace std;

const int Maxn=2e5+6,N=2e5;
bool st;
int f[2][Maxn],g[2][Maxn];
bool ed;
int ans[Maxn];
int T,n,p;

int main(){
	freopen("moon.in","r",stdin);
	freopen("moon.out","w",stdout); 

	scanf("%d%d",&T,&p);
	const int P=p;
	
	f[0][0]=1; g[0][0]=1;
	for(int i=1;i<=500;i++){
		int o=(i&1);
		for(int j=0;j<=N;j++) g[o][j]=f[o][j]=0;
		for(int j=1;j<=N;j++){
			if(j>=2*i) g[o][j]=(g[o][j]+f[o][j-2*i]+g[o][j-2*i])%P;
			f[o][j]=(f[o][j]+g[o^1][j-1])%P;
		}
		for(int j=1;j<=N;j++) ans[j]=(1ll*ans[j]+f[o][j]+g[o][j])%P;
	}		
	
	while(T--){
		scanf("%d",&n);
		printf("%d\n",ans[n]);
	}

	return 0;
}
/*
5 998244353
9
11
20
25
60

*/
